package com.rabbitmq.demo.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    // 消息队列
    @Bean
    public Queue contractQueue(){
        return new Queue("contractQueue",true);
    }

    // 交换机
    @Bean
    public DirectExchange ordersExchange(){
        return new DirectExchange("ordersExchange",true,false);
    }

    // 消息队列与交换机通过routingKey绑定
    @Bean
    Binding bindingDirect(Queue contractQueue, DirectExchange ordersExchange){
        return BindingBuilder.bind(contractQueue)
                .to(ordersExchange)
                .with("roming.pass.report.test");
    }
}
